package com.licheedev.somektxdemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.licheedev.myutils.LogPlus
import com.licheedev.someext.startActivity
import kotlinx.android.synthetic.main.activity_main.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.random.Random

class MainActivity : AppCompatActivity() {

    companion object {
        private const val TAG = "MainActivity"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val adatper = SampleAdatper()
        recyclerView.adapter = adatper

        val number = AtomicInteger(1)

        btnAddData.setOnClickListener {
            adatper.addData(SampleData(number.getAndIncrement()))
        }

        btnSetData.setOnClickListener {

            val prex = "${number.getAndIncrement()}_"

            val newData = (1..Random.nextInt(5, 12)).map { SampleData(prex + it) }
            LogPlus.e("新数据长度=${newData.size}")
            adatper.setNewData(newData)

        }


    }
}
